import { get } from '@/utils/storage';
// 检查本页路由是否存在权限
export function checkRoute(path) {
  // 如果传空，不验证权限
  if (!path) {
    return true;
  }
  let auth = get('auth');
  let route = auth.authList.find(r => {
    return r.route === path;
  });
  if (!route) {
    return false;
  } else {
    return true;
  }
}
export let auth = {
  bind(el, binding) {
      if(!binding.value) {
          throw new Error('v-auth指令必须传入值')
      }
    let authCode = binding.value.toString();
    let auth = get('auth');
    let previlege = auth[authCode];
    if (!previlege) {
      el.parentNode.removeChild(el);
    }
  }
};
